Skip to content

Add 30s init timeout and verify sync provider state#138

Merged
EtaCassiopeia merged 2 commits into
mainfrom
feat/init-timeout-and-sync-verify
May 13, 2026
Merged

Add 30s init timeout and verify sync provider state#138
EtaCassiopeia merged 2 commits into
mainfrom
feat/init-timeout-and-sync-verify

Conversation

@EtaCassiopeia
Copy link
Copy Markdown
Owner

@EtaCassiopeia EtaCassiopeia commented May 13, 2026

Summary

Implements #120 (init timeout) and #121 (verify sync init succeeded) — the first step of the 1.0-readiness workstream A.

  • A1 — initTimeout (default 30s) on both build and buildAsync private helpers.
    • Sync path: setProviderAndWait is wrapped with .disconnect.timeoutFail(TimeoutException(...))(initTimeout). The layer build fails fast instead of hanging on an unreachable / misconfigured provider.
    • Async path: a watchdog fiber forked into the layer's Scope sleeps initTimeout, then atomically transitions ProviderStatus.NotReady/Error to Fatal so callers polling providerStatus stop waiting. The fiber is interrupted when the layer is released.
    • Public overloads fromProvider(provider, evaluationTimeout, initTimeout) and fromProviderAsync(provider, evaluationTimeout, initTimeout) added for explicit control. All existing factories inherit the 30s default — no caller code needs to change.
  • A2 — Verify sync init. After setProviderAndWait returns, the new verifyInitState helper reads the underlying provider's state. READY / STALE are accepted; ERROR / FATAL / NOT_READY cause the layer build to fail with an IllegalStateException so misconfiguration surfaces at startup instead of at first evaluation.

New cases in core/src/test/scala/zio/openfeature/ProviderInitHardeningSpec.scala:

  • Sync fromProvider fails with TimeoutException when init blocks past initTimeout.
  • Sync fromProvider fails with IllegalStateException when provider reports ERROR after initialize().
  • Async watchdog transitions ProviderStatus to Fatal after initTimeout when init hangs.

Closes #120
Closes #121

@EtaCassiopeia EtaCassiopeia merged commit 9f720a6 into main May 13, 2026
1 check passed
@EtaCassiopeia EtaCassiopeia deleted the feat/init-timeout-and-sync-verify branch May 13, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core core module kind:feature new feature or behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[A2] Verify sync init actually succeeded before marking ProviderStatus.Ready [A1] Add initTimeout (default 30s) to fromProvider / fromProviderAsync

1 participant